

package cn.shengchao.examstar.distributor.gateway.controller;

import cn.shengchao.examstar.distributor.gateway.controller.query.StudentPageQuery;
import cn.shengchao.examstar.distributor.gateway.service.DistributorService;
import cn.shengchao.examstar.distributor.gateway.service.message.StudentData;
import cn.shengchao.examstar.rpc.base.PageResult;
import cn.shengchao.util.helper.LoginHelper;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import java.util.List;

@RestController
@Slf4j
@CrossOrigin("${project.cross-origin}")
@RequestMapping("/api/${project.version}/distributor/student")
public class DistributorStudentController {

    @Autowired
    private DistributorService distributorService;
    @GetMapping("page")
    public PageResult<StudentData> getStudentsDataPage(StudentPageQuery studentPageQuery) {
        return distributorService.getStudentsDataForNodeUser(LoginHelper.getUserId(), studentPageQuery);
    }
    @GetMapping()
    public List<StudentData> getStudentsData(@RequestParam("searchName") String searchName) {
        return distributorService.getStudentsData(LoginHelper.getUserId(), searchName);
    }
}
